<template>
  <div class="home">
    <div class="box">
      <div class="top">
        <div class="username_box">
          <el-popover
            placement="bottom"
            width="200"
            trigger="click">
            <div class="userinfo">
              <div class="baseinfo" @click.stop="showInfoDetail">
                <p class="name">丽丽</p>
                <div class="base_right">
                  <span class="name1">丽丽</span>
                  <p class="company_name">卡德曼信息技术</p>
                </div>
              </div>
              <p class="about" @click="about">关于我们</p>
              <p class="about" @click="loginout">退出登录</p>
            </div>
            <p class="username" slot="reference">丽丽</p>
          </el-popover>
          <baseinfo ref="baseinfo" @sendMsg='sendMsg'></baseinfo>
        </div>
        <!-- <span class="iconfont icon-quanju_tousu"></span> -->
        <el-popover
          placement="bottom"
          width="150"
          trigger="click">
          <ul class="more-oper">
            <li>
              <span class="iconfont icon-faqiliaotian"></span>
              <span>发起群聊</span>
            </li>
            <li>
              <span class="iconfont icon-tianjiayonghu"></span>
              <span>添加好友</span>
            </li>
          </ul>
          <span class="iconfont icon-add" slot="reference"></span>
        </el-popover>
      </div>
      <div class="bodycontent">
        <div class="navbar">
          <ul class="nav_center">
            <li :class="navActive==index?'active':''" @click="navChange(index)" v-for="(item,index) in navList" :key="index">
              <p class="nav_icon iconfont" :class="item.icon"></p>
              <span class="num" v-if="index==0">1</span>
              <p>{{item.name}}</p>
            </li>
          </ul>
          <div class="nav_bottom">
            <el-popover
              placement="right"
              width="150"
              trigger="click">
              <h1>更多应用</h1>
              <span class="iconfont icon-gengduo" slot="reference"></span>
            </el-popover>
          </div>
        </div>
        <div class="flex1">
          <message ref='message' v-if="navActive==0"></message>
          <workbench ref='workbench' v-else-if="navActive==1"></workbench>
          <maillist ref='message' v-else-if="navActive==2"></maillist>
          <calendar ref='message' v-else-if="navActive==3"></calendar>
          <meeting ref='message' v-else-if="navActive==4"></meeting>
        </div>
      </div>
    </div>
    <about ref='about'></about>
  </div>
</template>

<script>
import baseinfo from '@/components/baseinfo' // 个人基本信息弹框
import about from '@/components/about' // 关于我们弹框
import message from './message.vue' // 消息页面
import workbench from './workbench.vue' // 工作台页面
import maillist from './maillist.vue' // 通讯录页面
import calendar from './calendar.vue' // 日历页面
import meeting from './meeting.vue' // 会议页面
export default {
  name: 'Home',
  data() {
    return {
      navList:[
        {
          name:'消息',
          icon:'icon-xiaoxi',
        },
        {
          name:'工作台',
          icon:'icon-gongzuotai',
        },
        {
          name:'通讯录',
          icon:'icon-tongxunlu',
        },
        {
          name:'日历',
          icon:'icon-rili',
        },
        {
          name:'会议',
          icon:'icon-dianhua',
        }
      ], // 左侧导航菜单列表
      navActive:0,// 当前所选导航下标
    }
  },
  components: {
    baseinfo,
    about,
    message,
    workbench,
    maillist,
    calendar,
    meeting
  },
  mounted() {
    if (!window.localStorage.getItem('cadreuc_uid')) {
      this.$router.push('/login')
    }
  },
  methods:{
    // 导航切换
    navChange(idx) {
      this.navActive = idx
    },
    // 打开个人信息详情
    showInfoDetail() {
      this.$refs.baseinfo.show()
    },
    // 个人信息详情发送消息
    sendMsg() {
      this.navActive = 0
    },
    // 关于我们
    about() {
      this.$refs.about.show()
    },
    // 退出
    loginout() {
      window.localStorage.removeItem('cadreuc_uid')
      this.$router.push('/login')
    }
  }
}
</script>
<style lang='stylus' scoped>
@import '~@/assets/stylus/variable'
  .home
    height 100%
    background: url('~@/assets/images/bg.png') no-repeat center center
    background-size: cover
    display: flex
    align-items: center
    justify-content: center
    .box
      width: 67vw;
      height: 86vh;
      min-height: 700px;
      min-width: 900px;
      background #fff
      border-radius: 4px
      display: flex
      flex-direction: column
      .top
        height: 40px
        background #0076f6
        padding 5px 20px
        box-sizing border-box
        display: flex
        align-items: center
        justify-content: space-between
        .username
          width 30px
          height: 30px
          line-height: 30px
          color #fff
          font-size 12px
          background: $theme-color
          text-align: center
          cursor pointer
          border-radius 4px
        // .icon-quanju_tousu
        //   color #fff
        //   font-size 20px
        //   cursor pointer
        .icon-add
          color #fff
          margin-left: 10px
          font-size 24px
          cursor pointer
      .bodycontent
        flex 1
        min-height 0
        display: flex
        .navbar
          width: 54px
          border-right: 1px solid #f3f3f3
          text-align: center
          display: flex;
          flex-direction: column;
          background #eee
          padding 20px 10px
          .nav_center
            flex 1
            min-height 0
            li
              position: relative
              margin-bottom 15px
              text-align: center
              color #999
              font-size 12px
              cursor pointer
              padding 8px 0
              border-radius: 4px
              &.active
                background #ccc
                color #3d98ff
              .nav_icon
                font-size 22px
                margin-bottom 8px
                color #3d98ff
                font-weight bold
              .num
                position: absolute
                top 2px
                right 6px
                background: red;
                color: #fff;
                text-align: center;
                padding: 0 4px;
                height: 16px;
                line-height: 16px;
                font-size: 12px;
                border-radius: 10px;
          .nav_bottom
            cursor pointer
            position relative
            .icon-gengduo
              font-size 20px
            &:hover .icon-gengduo
              color #3d98ff
  .more-oper
    li
      padding 0 5px
      line-height: 40px
      font-size 14px
      .iconfont
        font-size 16px
        margin-right 6px
      &:hover
        background #f4f4f4
  .baseinfo
    display: flex
    align-items: center
    margin-bottom 10px
    cursor pointer
    .name
      width: 40px
      height: 40px
      background: #1662d5
      text-align: center
      line-height: 40px
      color #fff
      font-scale: 14px
      margin-right: 10px
    .base_right
      flex 1
      min-width: 0
      .name1
        font-size: 14px
        line-height: 20px
      .company_name
        font-size: 12px
        line-height: 20px
  .about
    line-height: 30px
    font-size: 14px
    cursor pointer
    &:hover
      color $theme-color
</style>